package com.ruoyi.service.jpjs.municipal.impl;

import com.ruoyi.common.constant.MsgConstants;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.domain.jpjs.common.municipal.Income;
import com.ruoyi.domain.jpjs.common.municipal.IncomeDetail;
import com.ruoyi.domain.jpjs.common.municipal.IncomeParam;
import com.ruoyi.domain.jpjs.common.municipal.Payment;
import com.ruoyi.domain.jpjs.common.municipal.expend.Team;
import com.ruoyi.mapper.jpjs.income.IncomeMapper;
import com.ruoyi.service.jpjs.municipal.IncomeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @explain 市政收入 业务层处理
 */
@Service
public class IncomeServiceImpl implements IncomeService {

    @Resource
    private IncomeMapper incomeMapper;

    @Override
    public List<Income> queryIncomeList(Income income) {
        return incomeMapper.queryIncomeList(income);
    }

    @Override
    public List<Income> queryIncomeListForCount(Income income) {
        return incomeMapper.queryIncomeListForCount(income);
    }

    @Override
    public List<Income> queryIncomeListForPay(Income income) {
        return incomeMapper.queryIncomeListForPay(income);
    }


    @Override
    public String checkMonthUnique(IncomeParam incomeParam) {
        int actualCount = incomeMapper.checkActualMonthUnique(incomeParam);
        int planCount = incomeMapper.checkPlanMonthUnique(incomeParam);
        if (actualCount > 0 || planCount > 0) {
            return MsgConstants.MONTH_NOT_UNIQUE;
        }
        return MsgConstants.MONTH_UNIQUE;
    }

    @Override
    public int addIncome(IncomeParam incomeParam) {
        return incomeMapper.addIncome(incomeParam);
    }

    @Override
    public int addIncomeDetail(List<IncomeDetail> incomeDetail) {
        return incomeMapper.addIncomeDetail(incomeDetail);
    }

    @Override
    public List<IncomeDetail> queryIncomeDetail(Map<String, Object> map) {
        return incomeMapper.queryIncomeDetail(map);
    }

    @Override
    public int deleteIncomeById(String detail) {
        String[] detailId = Convert.toStrArray(detail);
        return incomeMapper.deleteIncomeById(detailId);
    }

    @Override
    public String checkMonthUniqueEdit(IncomeParam incomeParam) {
        int actualCount = incomeMapper.checkActualMonthUniqueEdit(incomeParam);
        int planCount = incomeMapper.checkPlanMonthUniqueEdit(incomeParam);
        if (actualCount > 0 || planCount > 0) {
            return MsgConstants.MONTH_NOT_UNIQUE;
        }
        return MsgConstants.MONTH_UNIQUE;
    }

    @Override
    public int updateIncome(IncomeParam incomeParam) {
        return incomeMapper.updateIncome(incomeParam);
    }

    @Override
    public int deleteIncomeDetail(IncomeParam incomeParam) {
        return incomeMapper.deleteIncomeDetail(incomeParam);
    }

    @Override
    public List<Income> queryIncomeObj(Map<String, Object> map) {
        return incomeMapper.queryIncomeObj(map);
    }

    @Override
    public List<IncomeDetail> queryIncomeDetailMonth(Map<String, Object> map) {
        return incomeMapper.queryIncomeDetailMonth(map);
    }

    @Override
    public int deletePayment() {
        return incomeMapper.deletePayment();
    }

    @Override
    public int insertPayment(Payment payment) {
        return incomeMapper.insertPayment(payment);
    }

}
